package com.easybacklog.client.cucumberfeatures.edit;

import com.easybacklog.client.model.ProjectFeature;
import com.google.gwt.user.client.ui.VerticalPanel;

import edu.ycp.cs.dh.acegwt.client.ace.AceEditor;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorMode;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorTheme;

/** 
 * 
 * 
 * @Architecture 
 */

public class AceGWTEditor {

	private AceEditor editor;

	public void showCodeEditor(ProjectFeature feature) {

		editor = new AceEditor();
		editor.setSize("700px", "500px");

		VerticalPanel mainPanel = new VerticalPanel();
		mainPanel.setSize("700px", "500px");
		mainPanel.setBorderWidth(1);

		mainPanel.add(editor);

		BacklogFeatureFileView.vpSourceCode.clear();
		BacklogFeatureFileView.vpSourceCode.add(mainPanel);

		// start the first editor and set its theme and mode
		// must be called before calling setTheme/setMode/etc.
		editor.startEditor();

		editor.setTheme(AceEditorTheme.ECLIPSE);
		editor.setMode(AceEditorMode.XML);

		editor.setText(feature.getFileContent());

		editor.setHScrollBarAlwaysVisible(false);

		editor.gotoLine(0);
	}

}
